window.__require = function e(t, a, l) {
    function n(o, c) {
        if (!a[o]) {
            if (!t[o]) {
                var s = o.split("/");
                if (s = s[s.length - 1], !t[s]) {
                    var i = "function" == typeof __require && __require;
                    if (!c && i) return i(s, !0);
                    if (r) return r(s, !0);
                    throw new Error("Cannot find module '" + o + "'")
                }
                o = s
            }
            var u = a[o] = {
                exports: {}
            };
            t[o][0].call(u.exports, function (e) {
                return n(t[o][1][e] || e)
            }, u, u.exports, e, t, a, l)
        }
        return a[o].exports
    }
    for (var r = "function" == typeof __require && __require, o = 0; o < l.length; o++) n(l[o]);
    return n
}({
    RankItem: [function (e, t, a) {
        "use strict";
        cc._RF.push(t, "39c54YEh51B0ro1dmNecyow", "RankItem"), cc.Class({
            extends: cc.Component,
            properties: {
                labelRank: {
                    type: cc.Label,
                    default: null
                },
                labelName: {
                    type: cc.Label,
                    default: null
                },
                labelScore: {
                    type: cc.Label,
                    default: null
                },
                avator: {
                    type: cc.Sprite,
                    default: null
                },
                avatorMask: {
                    type: cc.Node,
                    default: null
                },
                top1Sprite: {
                    type: cc.SpriteFrame,
                    default: null
                },
                top2Sprite: {
                    type: cc.SpriteFrame,
                    default: null
                },
                top3Sprite: {
                    type: cc.SpriteFrame,
                    default: null
                },
                normalSprite: {
                    type: cc.SpriteFrame,
                    default: null
                },
                rankSprite: {
                    type: cc.Sprite,
                    default: null
                }
            },
            setUser: function (e, t, a) {
                for (var l, n = this, r = e.nickName ? e.nickName : e.nickname, o = e.avatarUrl, c = e.KVDataList, s = null, i = 0; i < c.length; i++)
                    if (4 == a) {
                        if ("limit_level" == c[i].key) {
                            s = c[i];
                            break
                        }
                    } else if ("score" == c[i].key) {
                    s = c[i];
                    break
                }(console.log("setUser user: ", e), console.log("setUser kvData: ", s), null != s) ? (0 == c.length ? l = 1 : (l = s.value, isNaN(parseInt(l)) && (l = 1)), 1 == t ? (this.rankSprite.getComponent(cc.Sprite).spriteFrame = this.top1Sprite, this.labelRank.node.active = !1) : 2 == t ? (this.rankSprite.getComponent(cc.Sprite).spriteFrame = this.top2Sprite, this.labelRank.node.active = !1) : 3 == t ? (this.rankSprite.getComponent(cc.Sprite).spriteFrame = this.top3Sprite, this.labelRank.node.active = !1) : (this.rankSprite.getComponent(cc.Sprite).spriteFrame = null, this.labelRank.node.active = !0), console.log("jiaji item height =  " + this.node.height), console.log("user level " + l), console.log("user name = " + r), console.log("game.levelArray index", parseInt(l)), this.labelRank.string = t + "", this.labelScore.string = l + "\u5206", this.labelName.string = r, console.log(r + "'s info has been getten."), "" != o && cc.loader.load({
                    url: o,
                    type: "png"
                }, function (e, t) {
                    e && console.error(e), n.avator.spriteFrame = new cc.SpriteFrame(t), console.log("this.avatormask width = " + n.avator.node.width + ",height = " + n.avator.node.height)
                })) : this.node.active = !1
            },
            onLoad: function () {},
            start: function () {}
        }), cc._RF.pop()
    }, {}],
    SubMain: [function (e, t, a) {
        "use strict";
        cc._RF.push(t, "6cbb3i+TTZNiakF968XBpue", "SubMain"), cc.Class({
            extends: cc.Component,
            properties: {
                rankItemPrefab: {
                    type: cc.Prefab,
                    default: null
                },
                content: {
                    type: cc.Node,
                    default: null
                },
                _data: {
                    type: cc.Object,
                    default: null
                },
                _currentUserdata: {
                    type: cc.Object,
                    default: null
                },
                _beforeUserdata: {
                    type: cc.Object,
                    default: null
                },
                _nextUserdata: {
                    type: cc.Object,
                    default: null
                },
                scrollerNode: {
                    type: cc.Node,
                    default: null
                },
                rankNode: {
                    type: cc.Node,
                    default: null
                },
                nextNode: {
                    type: cc.Node,
                    default: null
                },
                before: {
                    type: cc.Sprite,
                    default: null
                },
                my: {
                    type: cc.Sprite,
                    default: null
                },
                next: {
                    type: cc.Sprite,
                    default: null
                },
                beforeLable: {
                    type: cc.Label,
                    default: null
                },
                myLable: {
                    type: cc.Label,
                    default: null
                },
                nextLable: {
                    type: cc.Label,
                    default: null
                },
                beforeLevel: {
                    type: cc.Label,
                    default: null
                },
                myLevel: {
                    type: cc.Label,
                    default: null
                },
                nextLevel: {
                    type: cc.Label,
                    default: null
                },
                nextlevellayout: {
                    type: cc.Node,
                    default: null
                },
                nextlevelImage: {
                    type: cc.Sprite,
                    default: null
                },
                nextlevelLable: {
                    type: cc.Label,
                    default: null
                },
                selfRank: {
                    type: cc.Label,
                    default: null
                },
                selfRankIcon: {
                    type: cc.Sprite,
                    default: null
                },
                selfRankName: {
                    type: cc.Label,
                    default: null
                },
                selfRankLevel: {
                    type: cc.Label,
                    default: null
                },
                scrollView: {
                    type: cc.Node,
                    default: null
                }
            },
            onLoad: function () {
                var e = this;
                this.type = 0, wx.onMessage(function (t) {
                    console.log("start update"), e.scrollerNode.active = !1, e.rankNode.active = !1, e.nextNode.active = !1, null != t.message && "message" == t.message && (e.pageIndex = 0, e.updateRankData(), e.type = Number(t.type))
                }), this.pageSize = 5, console.log("screen width =" + cc.winSize.width + ",height = " + cc.winSize.height);
                cc.winSize.height, cc.winSize.width
            },
            isNull: function (e) {
                return !(!isNaN(e) && "" != e)
            },
            start: function () {},
            updateRankData: function () {
                console.log("updateRankData");
                var e = this;
                wx.getFriendCloudStorage({
                    keyList: ["score"],
                    success: function (t) {
                        if (console.log("length = " + t.data.length), console.log("res", t.data), t.data.length > 0) {
                            e.sortList(t.data, !1, e.type), e._data = t.data;
                            var a = cc.Canvas.instance;
                            0 == e.type || 4 == e.type ? (a.height = 500, a.width = 320, e.scrollerNode.active = !0, e.rankNode.active = !1, e.nextNode.active = !1, e.updatePageData()) : 1 == e.type || 3 == e.type ? (a.height = 451, a.width = 453, e.scrollerNode.active = !1, e.rankNode.active = !0, e.nextNode.active = !1, e.getUserData()) : 2 == e.type && (e.scrollerNode.active = !1, e.rankNode.active = !1, e.nextNode.active = !0, e.getUserData())
                        }
                    },
                    fail: function (e) {
                        console.error("geterror" + e)
                    }
                })
            },
            getUserData: function () {
                var e = this;
                wx.getUserInfo({
                    openIdList: ["selfOpenId"],
                    success: function (t) {
                        console.log("getUserData: ", t), console.log("getUserData res:", t.data), console.log("res.data[0].avatarUrl: ", t.data[0].avatarUrl), console.log("res.data[0].nickName: ", t.data[0].nickName);
                        for (var a = 0; a < e._data.length; a++)
                            if (console.log("_self._data[i].avatarUrl: ", e._data[a].avatarUrl), console.log("_self._data[i].nickName: ", e._data[a].nickname), e._data[a].avatarUrl == t.data[0].avatarUrl && e._data[a].nickname == t.data[0].nickName) {
                                e._currentUserdata = e._data[a], e._nextUserdata = null;
                                for (var l = a; l >= 0; l--) Number(e.getLevelByUser(e._data[l])) > Number(e.getLevelByUser(e._currentUserdata)) && (e._nextUserdata = e._data[l]);
                                e._beforeUserdata = null;
                                for (var n = a; n < e._data.length - 1; n++) Number(e.getLevelByUser(e._data[n])) < Number(e.getLevelByUser(e._currentUserdata)) && (e._beforeUserdata = e._data[n]);
                                break
                            } if (1 == e.type || 3 == e.type) console.log("_self._beforeUserdata: ", e._beforeUserdata), null != e._beforeUserdata ? (e.before.node.active = !0, e.showUser(e.before, e.beforeLable, e.beforeLevel, e._beforeUserdata)) : (console.log("_self.before.active = fasle "), e.before.node.active = !1), console.log("_self._currentUserdata: ", e._currentUserdata), null != e._currentUserdata ? (e.my.node.active = !0, e.showUser(e.my, e.myLable, e.myLevel, e._currentUserdata)) : e.my.node.active = !1, console.log("_self._nextUserdata: ", e._nextUserdata), null != e._nextUserdata ? (e.next.node.active = !0, e.showUser(e.next, e.nextLable, e.nextLevel, e._nextUserdata)) : e.next.node.active = !1;
                        else if (console.log("_self._nextUserdata: ", e._nextUserdata), null != e._nextUserdata) {
                            e.nextlevellayout.active = !0, e.showUser2(e.nextlevelImage, e._nextUserdata);
                            Number(e.getLevelByUser(e._nextUserdata)), Number(e.getLevelByUser(e._currentUserdata))
                        } else e.nextlevellayout.active = !1
                    },
                    fail: function (e) {
                        console.error("geterror" + e)
                    }
                })
            },
            updatePageData: function () {
                this.content.removeAllChildren();
                var e = this;
                wx.getUserInfo({
                    openIdList: ["selfOpenId"],
                    success: function (t) {
                        console.log("jiaji scroll view top : ", e.node.getBoundingBoxToWorld()), console.log("updatePageData rank list: ", t), console.log("updatePageData res:", t.data), console.log("res.data[0].avatarUrl: ", t.data[0].avatarUrl), console.log("res.data[0].nickName: ", t.data[0].nickName);
                        for (var a = 0; a < e._data.length; a++) {
                            console.log("_self._data[i].avatarUrl: ", e._data[a].avatarUrl), console.log("_self._data[i].nickName: ", e._data[a].nickname), console.log("_self.friendInfo: ", l);
                            var l = e._data[a],
                                n = e.createPrefab().getComponent("RankItem");
                            if (n.setUser(l, a + 1, e.type), e.content.addChild(n.node), l.avatarUrl == t.data[0].avatarUrl && l.nickname == t.data[0].nickName) {
                                var r = l;
                                e.selfRank.string = a + "1";
                                var o = l.avatarUrl;
                                cc.loader.load({
                                    url: o,
                                    type: "png"
                                }, function (t, a) {
                                    t && console.error(t), e.selfRankIcon.spriteFrame = new cc.SpriteFrame(a)
                                }), e.selfRankName.string = r.nickname, console.log("_self.selfRankLevel: ", e.getLevelByUser(r)), e.selfRankLevel.string = e.getLevelByUser(r) + "\u5206"
                            }
                        }
                        e.scrollView.getComponent(cc.ScrollView).scrollToOffset(cc.v2(0, 0))
                    }
                })
            },
            updateThreeRankData: function () {},
            updateNextUserData: function () {},
            showUser: function (e, t, a, l) {
                var n = l.nickname,
                    r = l.avatarUrl;
                t.string = n, a.string = this.getLevelByUser(l) + "\u5206", console.log(n + "'s info has been getten."), cc.loader.load({
                    url: r,
                    type: "png"
                }, function (t, a) {
                    t && console.error(t), e.spriteFrame = new cc.SpriteFrame(a)
                })
            },
            showUser2: function (e, t) {
                var a = t.avatarUrl;
                cc.loader.load({
                    url: a,
                    type: "png"
                }, function (t, a) {
                    t && console.error(t), e.spriteFrame = new cc.SpriteFrame(a)
                })
            },
            createPrefab: function () {
                var e = cc.instantiate(this.rankItemPrefab);
                return e.width = this.content.width, e.x = 0, e
            },
            sortList: function (e, t, a) {
                return e.sort(function (e, l) {
                    for (var n = 0, r = e.KVDataList, o = 0; o < r.length; o++) 3 == a || 4 == a ? "limit_level" == r[o].key && (n = r[o].value) : "score" == r[o].key && (n = r[o].value);
                    var c = 0;
                    r = l.KVDataList;
                    for (o = 0; o < r.length; o++) 3 == a || 4 == a ? "limit_level" == r[o].key && (c = r[o].value) : "score" == r[o].key && (c = r[o].value);
                    return isNaN(parseInt(n)) && (n = 1), isNaN(parseInt(c)) && (c = 1), t ? parseInt(n) - parseInt(c) : parseInt(c) - parseInt(n)
                }), e
            },
            getLevelByUser: function (e) {
                for (var t = e.KVDataList, a = 0; a < t.length; a++)
                    if (3 == this.type || 4 == this.type) {
                        if ("limit_level" == t[a].key) return t[a].value
                    } else if ("score" == t[a].key) return t[a].value;
                return 0
            }
        }), cc._RF.pop()
    }, {}],
    "use_v2.1-2.2.1_cc.Toggle_event": [function (e, t, a) {
        "use strict";
        cc._RF.push(t, "a8d9bcFwzBLIJVJhxDlm/Yc", "use_v2.1-2.2.1_cc.Toggle_event"), cc.Toggle && (cc.Toggle._triggerEventInScript_isChecked = !0), cc._RF.pop()
    }, {}]
}, {}, ["RankItem", "SubMain", "use_v2.1-2.2.1_cc.Toggle_event"]);